// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PyCracksClipperAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>

// ****************************************************************************
// Module: PyCracksClipperAttributes
//
// Purpose:
//   Attributes for the cracks clipper operator
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a CracksClipperAttributes.
//
struct CracksClipperAttributesObject
{
    PyObject_HEAD
    CracksClipperAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewCracksClipperAttributes(int);
std::string
PyCracksClipperAttributes_ToString(const CracksClipperAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    snprintf(tmpStr, 1000, "%scrack1Var = \"%s\"\n", prefix, atts->GetCrack1Var().c_str());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%scrack2Var = \"%s\"\n", prefix, atts->GetCrack2Var().c_str());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%scrack3Var = \"%s\"\n", prefix, atts->GetCrack3Var().c_str());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sstrainVar = \"%s\"\n", prefix, atts->GetStrainVar().c_str());
    str += tmpStr;
    if(atts->GetShowCrack1())
        snprintf(tmpStr, 1000, "%sshowCrack1 = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sshowCrack1 = 0\n", prefix);
    str += tmpStr;
    if(atts->GetShowCrack2())
        snprintf(tmpStr, 1000, "%sshowCrack2 = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sshowCrack2 = 0\n", prefix);
    str += tmpStr;
    if(atts->GetShowCrack3())
        snprintf(tmpStr, 1000, "%sshowCrack3 = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sshowCrack3 = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sinMassVar = \"%s\"\n", prefix, atts->GetInMassVar().c_str());
    str += tmpStr;
    return str;
}

static PyObject *
CracksClipperAttributes_Notify(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CracksClipperAttributes_SetCrack1Var(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the crack1Var in the object.
    obj->data->SetCrack1Var(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CracksClipperAttributes_GetCrack1Var(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetCrack1Var().c_str());
    return retval;
}

/*static*/ PyObject *
CracksClipperAttributes_SetCrack2Var(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the crack2Var in the object.
    obj->data->SetCrack2Var(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CracksClipperAttributes_GetCrack2Var(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetCrack2Var().c_str());
    return retval;
}

/*static*/ PyObject *
CracksClipperAttributes_SetCrack3Var(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the crack3Var in the object.
    obj->data->SetCrack3Var(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CracksClipperAttributes_GetCrack3Var(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetCrack3Var().c_str());
    return retval;
}

/*static*/ PyObject *
CracksClipperAttributes_SetStrainVar(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the strainVar in the object.
    obj->data->SetStrainVar(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CracksClipperAttributes_GetStrainVar(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetStrainVar().c_str());
    return retval;
}

/*static*/ PyObject *
CracksClipperAttributes_SetShowCrack1(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the showCrack1 in the object.
    obj->data->SetShowCrack1(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CracksClipperAttributes_GetShowCrack1(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetShowCrack1()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CracksClipperAttributes_SetShowCrack2(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the showCrack2 in the object.
    obj->data->SetShowCrack2(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CracksClipperAttributes_GetShowCrack2(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetShowCrack2()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CracksClipperAttributes_SetShowCrack3(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the showCrack3 in the object.
    obj->data->SetShowCrack3(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CracksClipperAttributes_GetShowCrack3(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetShowCrack3()?1L:0L);
    return retval;
}

/*static*/ PyObject *
CracksClipperAttributes_SetInMassVar(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the inMassVar in the object.
    obj->data->SetInMassVar(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
CracksClipperAttributes_GetInMassVar(PyObject *self, PyObject *args)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetInMassVar().c_str());
    return retval;
}



PyMethodDef PyCracksClipperAttributes_methods[CRACKSCLIPPERATTRIBUTES_NMETH] = {
    {"Notify", CracksClipperAttributes_Notify, METH_VARARGS},
    {"SetCrack1Var", CracksClipperAttributes_SetCrack1Var, METH_VARARGS},
    {"GetCrack1Var", CracksClipperAttributes_GetCrack1Var, METH_VARARGS},
    {"SetCrack2Var", CracksClipperAttributes_SetCrack2Var, METH_VARARGS},
    {"GetCrack2Var", CracksClipperAttributes_GetCrack2Var, METH_VARARGS},
    {"SetCrack3Var", CracksClipperAttributes_SetCrack3Var, METH_VARARGS},
    {"GetCrack3Var", CracksClipperAttributes_GetCrack3Var, METH_VARARGS},
    {"SetStrainVar", CracksClipperAttributes_SetStrainVar, METH_VARARGS},
    {"GetStrainVar", CracksClipperAttributes_GetStrainVar, METH_VARARGS},
    {"SetShowCrack1", CracksClipperAttributes_SetShowCrack1, METH_VARARGS},
    {"GetShowCrack1", CracksClipperAttributes_GetShowCrack1, METH_VARARGS},
    {"SetShowCrack2", CracksClipperAttributes_SetShowCrack2, METH_VARARGS},
    {"GetShowCrack2", CracksClipperAttributes_GetShowCrack2, METH_VARARGS},
    {"SetShowCrack3", CracksClipperAttributes_SetShowCrack3, METH_VARARGS},
    {"GetShowCrack3", CracksClipperAttributes_GetShowCrack3, METH_VARARGS},
    {"SetInMassVar", CracksClipperAttributes_SetInMassVar, METH_VARARGS},
    {"GetInMassVar", CracksClipperAttributes_GetInMassVar, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
CracksClipperAttributes_dealloc(PyObject *v)
{
   CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *CracksClipperAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PyCracksClipperAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "crack1Var") == 0)
        return CracksClipperAttributes_GetCrack1Var(self, NULL);
    if(strcmp(name, "crack2Var") == 0)
        return CracksClipperAttributes_GetCrack2Var(self, NULL);
    if(strcmp(name, "crack3Var") == 0)
        return CracksClipperAttributes_GetCrack3Var(self, NULL);
    if(strcmp(name, "strainVar") == 0)
        return CracksClipperAttributes_GetStrainVar(self, NULL);
    if(strcmp(name, "showCrack1") == 0)
        return CracksClipperAttributes_GetShowCrack1(self, NULL);
    if(strcmp(name, "showCrack2") == 0)
        return CracksClipperAttributes_GetShowCrack2(self, NULL);
    if(strcmp(name, "showCrack3") == 0)
        return CracksClipperAttributes_GetShowCrack3(self, NULL);
    if(strcmp(name, "inMassVar") == 0)
        return CracksClipperAttributes_GetInMassVar(self, NULL);


    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PyCracksClipperAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PyCracksClipperAttributes_methods[i].ml_name),
                PyString_FromString(PyCracksClipperAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PyCracksClipperAttributes_methods, self, name);
}

int
PyCracksClipperAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "crack1Var") == 0)
        obj = CracksClipperAttributes_SetCrack1Var(self, args);
    else if(strcmp(name, "crack2Var") == 0)
        obj = CracksClipperAttributes_SetCrack2Var(self, args);
    else if(strcmp(name, "crack3Var") == 0)
        obj = CracksClipperAttributes_SetCrack3Var(self, args);
    else if(strcmp(name, "strainVar") == 0)
        obj = CracksClipperAttributes_SetStrainVar(self, args);
    else if(strcmp(name, "showCrack1") == 0)
        obj = CracksClipperAttributes_SetShowCrack1(self, args);
    else if(strcmp(name, "showCrack2") == 0)
        obj = CracksClipperAttributes_SetShowCrack2(self, args);
    else if(strcmp(name, "showCrack3") == 0)
        obj = CracksClipperAttributes_SetShowCrack3(self, args);
    else if(strcmp(name, "inMassVar") == 0)
        obj = CracksClipperAttributes_SetInMassVar(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
CracksClipperAttributes_print(PyObject *v, FILE *fp, int flags)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)v;
    fprintf(fp, "%s", PyCracksClipperAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
CracksClipperAttributes_str(PyObject *v)
{
    CracksClipperAttributesObject *obj = (CracksClipperAttributesObject *)v;
    return PyString_FromString(PyCracksClipperAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *CracksClipperAttributes_Purpose = "Attributes for the cracks clipper operator";
#else
static char *CracksClipperAttributes_Purpose = "Attributes for the cracks clipper operator";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(CracksClipperAttributesType,         \
                  "CracksClipperAttributes",           \
                  CracksClipperAttributesObject,       \
                  CracksClipperAttributes_dealloc,     \
                  CracksClipperAttributes_print,       \
                  PyCracksClipperAttributes_getattr,   \
                  PyCracksClipperAttributes_setattr,   \
                  CracksClipperAttributes_str,         \
                  CracksClipperAttributes_Purpose,     \
                  CracksClipperAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
CracksClipperAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &CracksClipperAttributesType
         || Py_TYPE(other) != &CracksClipperAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    CracksClipperAttributes *a = ((CracksClipperAttributesObject *)self)->data;
    CracksClipperAttributes *b = ((CracksClipperAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static CracksClipperAttributes *defaultAtts = 0;
static CracksClipperAttributes *currentAtts = 0;

static PyObject *
NewCracksClipperAttributes(int useCurrent)
{
    CracksClipperAttributesObject *newObject;
    newObject = PyObject_NEW(CracksClipperAttributesObject, &CracksClipperAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new CracksClipperAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new CracksClipperAttributes(*defaultAtts);
    else
        newObject->data = new CracksClipperAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapCracksClipperAttributes(const CracksClipperAttributes *attr)
{
    CracksClipperAttributesObject *newObject;
    newObject = PyObject_NEW(CracksClipperAttributesObject, &CracksClipperAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (CracksClipperAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
CracksClipperAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewCracksClipperAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef CracksClipperAttributesMethods[] = {
    {"CracksClipperAttributes", CracksClipperAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *CracksClipperAttributesObserver = 0;

std::string
PyCracksClipperAttributes_GetLogString()
{
    std::string s("CracksClipperAtts = CracksClipperAttributes()\n");
    if(currentAtts != 0)
        s += PyCracksClipperAttributes_ToString(currentAtts, "CracksClipperAtts.", true);
    return s;
}

static void
PyCracksClipperAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("CracksClipperAtts = CracksClipperAttributes()\n");
        s += PyCracksClipperAttributes_ToString(currentAtts, "CracksClipperAtts.", true);
        cb(s);
    }
}

void
PyCracksClipperAttributes_StartUp(CracksClipperAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PyCracksClipperAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(CracksClipperAttributesObserver == 0)
    {
        CracksClipperAttributesObserver = new ObserverToCallback(subj,
            PyCracksClipperAttributes_CallLogRoutine, (void *)data);
    }

}

void
PyCracksClipperAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete CracksClipperAttributesObserver;
    CracksClipperAttributesObserver = 0;
}

PyMethodDef *
PyCracksClipperAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return CracksClipperAttributesMethods;
}

bool
PyCracksClipperAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &CracksClipperAttributesType);
}

CracksClipperAttributes *
PyCracksClipperAttributes_FromPyObject(PyObject *obj)
{
    CracksClipperAttributesObject *obj2 = (CracksClipperAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PyCracksClipperAttributes_New()
{
    return NewCracksClipperAttributes(0);
}

PyObject *
PyCracksClipperAttributes_Wrap(const CracksClipperAttributes *attr)
{
    return WrapCracksClipperAttributes(attr);
}

void
PyCracksClipperAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    CracksClipperAttributesObject *obj2 = (CracksClipperAttributesObject *)obj;
    obj2->parent = parent;
}

void
PyCracksClipperAttributes_SetDefaults(const CracksClipperAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new CracksClipperAttributes(*atts);
}

